package com.ych.modules.common.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.ych.modules.base.dbEntity.TUserAccountChangeEntity;
import com.ych.modules.base.service.ITUserAccountChangeService;
import com.ych.modules.common.service.UserAccountChangeService;
import com.ych.modules.common.entity.query.QueryUserAccountChangeEntity;
import com.ych.utils.beanToMap.BeanMapUtil;
import com.ych.utils.mysqlPageUtil.Query;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created with IntelliJ IDEA.
 * Author: Usopp.tsui
 * Date: 2020/12/31
 * Time: 15:13
 * Description:
 */
@Service("UserAccountChangeService")
public class UserAccountChangeServiceImpl implements UserAccountChangeService {
    @Autowired
    private ITUserAccountChangeService itUserAccountChangeService;

    @Override
    public Page<TUserAccountChangeEntity> listUserAccountChange(QueryUserAccountChangeEntity entity) {
        Wrapper<TUserAccountChangeEntity> wrapper = new EntityWrapper<TUserAccountChangeEntity>()
                .where("1=1")
                .eq(StringUtils.isNotBlank(entity.getUserId()), "user_id", entity.getUserId())
                .eq(StringUtils.isNotBlank(entity.getAccountTrend()), "account_trend", entity.getAccountTrend())
                .eq(StringUtils.isNotBlank(entity.getAccountChangeBusinessType()), "account_change_business_type", entity.getAccountChangeBusinessType())
                .orderBy("create_time DESC");
        Page<TUserAccountChangeEntity> page = itUserAccountChangeService.selectPage(new Query<TUserAccountChangeEntity>(BeanMapUtil.toPageQuery(entity)).getPage(), wrapper);
        return page;
    }
}
